#!/bin/bash
#site: www.jquerycn.cn
function ergodic(){
  for file in `ls $1`
  do
    if [ -d $1"/"$file -a "${file}" != face_base ]
    then
      cd ${file}
      for img_file in `ls ./`
      do
        if [[ "${img_file}" == *jpg ]];then
          echo "image file name ${img_file}"
          cp ${img_file} "../"$2"/"${file}"_"${img_file}
        fi
      done
      cd ../ 
    else
      echo "this is a file" 
    fi
  done
}
IFS=$'\n' #这个必须要，否则会在文件名中有空格时出错
INIT_PATH=".";
dst_dir="./face_base"
ergodic $INIT_PATH $dst_dir
